package com.zjhs.media.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zjhs.common.annotation.Log;
import com.zjhs.common.core.controller.BaseController;
import com.zjhs.common.core.domain.AjaxResult;
import com.zjhs.common.enums.BusinessType;
import com.zjhs.media.domain.${ClassName};
import com.zjhs.media.service.I${ClassName}Service;
import com.zjhs.common.utils.poi.ExcelUtil;
import com.zjhs.common.core.page.TableDataInfo;

/**
 *  ${table.comment}
 * 
 * @author ruoyi
 * @date 2022-11-09
 */
@Api(value = "/${className}",tags = "${table.comment}")
@RestController
@RequestMapping("/${className}")
public class ${ClassName}Controller extends BaseController
{
    @Autowired
    private I${ClassName}Service ${className}Service;

    /**
     * 查询${table.comment}列表
     */
    @ApiOperation(value = "查询${table.comment}列表", notes = "查询稿${table.comment}列表")
    @PreAuthorize("@ss.hasPermi('system:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(${ClassName} ${className})
    {
        startPage();
        List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
        return getDataTable(list);
    }

    /**
     * 导出${table.comment}列表
     */
    @ApiOperation(value = "导出${table.comment}列表", notes = "导出${table.comment}列表")
    @PreAuthorize("@ss.hasPermi('system:info:export')")
    @Log(title = "${table.comment}", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ${ClassName} ${className})
    {
        List<${ClassName}> list = ${className}Service.select${ClassName}List( ${className});
        ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}.class);
        util.exportExcel(response, list, "${table.comment}数据");
    }

    /**
     * 获取${table.comment}详细信息
     */
    @ApiOperation(value = "获取${table.comment}详细信息", notes = "获取${table.comment}详细信息")
    @PreAuthorize("@ss.hasPermi('system:info:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(${className}Service.select${ClassName}ById(id));
    }

    /**
     * 新增${table.comment}
     */
    @ApiOperation(value = "新增${table.comment}", notes = "新增${table.comment}")
    @PreAuthorize("@ss.hasPermi('system:info:add')")
    @Log(title = "${table.comment}", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ${ClassName} ${className})
    {
        return toAjax(${className}Service.insert${ClassName}(${className}));
    }

    /**
     * 修改${table.comment}
     */
    @ApiOperation(value = "修改${table.comment}", notes = "修改${table.comment}")
    @PreAuthorize("@ss.hasPermi('system:info:edit')")
    @Log(title = "${table.comment}", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ${ClassName} ${className})
    {
        return toAjax(${className}Service.update${ClassName}(${className}));
    }

    /**
     * 删除${table.comment}
     */
    @ApiOperation(value = "删除${table.comment}", notes = "删除${table.comment}")
    @PreAuthorize("@ss.hasPermi('system:info:remove')")
    @Log(title = "${table.comment}", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(${className}Service.delete${ClassName}ByIds(ids));
    }
}
